export const tableRequestMock1 = e => {
	console.log("tableRequest e", e);
	const { pageNum, pageSize } = e;
	return new Promise((resolve, reject) => {
		const total = 10;
		const records = [];
		const start = (pageNum - 1) * pageSize;
		const end = pageNum * pageSize;

		const minEnd = Math.min(end, total);
		for (let index = start; index < minEnd; index++) {
			records.push({
				id: index,
				ecStoreId: "ecStoreId" + index,
				skuCode: "code" + index,
				skuName: "skuName" + index,
				ecStoreName: "ecStoreName" + index,
				sysType: "1",
				skuSaleStatus: "xj",
				image: "https://img2.baidu.com/it/u=4290083489,2727678970&fm=253&fmt=auto&app=120&f=JPEG?w=626&h=459",
				ecStoreLogo: "https://img1.baidu.com/it/u=1861457511,1830849359&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=400"
			});
		}

		setTimeout(() => {
			resolve({
				code: 200,
				success: true,
				data: {
					current: pageNum,
					records,
					total,
					size: pageSize
				},
				msg: "操作成功",
				v: "v1.0"
			});
		}, 1000);
	});
};

const getItems = n => {
	const d = [];

	for (let index = 0; index < n; index++) {
		d.push({
			id: n + "-" + index,
			seq: "seq" + Math.random() + "",
			spuCode: "spuCode" + n + "-" + index,
			skuCode: "code" + n + "-" + index,
			skuName: "skuName" + n + "-" + index,
			skuSpec: "skuSpec" + n + "-" + index,

			skuImage: "https://gw.alipayobjects.com/zos/rmsportal/KDpgvguMpGfqaHPjicRK.svg"
		});
	}
	return d;
};
export const tableRequestMockSoldPurchase = e => {
	console.log("tableRequest e", e);
	const { pageNum, pageSize } = e;
	return new Promise((resolve, reject) => {
		const total = 108;
		const records = [];
		const start = (pageNum - 1) * pageSize;
		const end = pageNum * pageSize;

		for (let index = start; index < end; index++) {
			records.push({
				id: index,
				seq: "seq" + Math.random() + "",
				supplierName: "ecStoreId" + index,
				supplierArea: "code" + index,
				allPrice: 6256 + index,
				allCount: 65165 + index,
				sysType: "1",
				skuSaleStatus: "xj",
				children: getItems(index + 1)
			});
		}

		setTimeout(() => {
			resolve({
				code: 200,
				success: true,
				data: {
					current: pageNum,
					records,
					total,
					size: pageSize
				},
				msg: "操作成功",
				v: "v1.0"
			});
		}, 1000);
	});
};
